﻿namespace GoodAdmin.Core;

/// <summary>
/// 框架实体基类Id
/// </summary>
public abstract class BaseEntityId
{
    /// <summary>
    /// 雪花Id
    /// </summary>
    [SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true, IsIdentity = false)]
    public virtual long Id { get; set; }
}


/// <summary>
/// 框架实体基类自增Id
/// </summary>
public abstract class BaseIncrementId
{
    /// <summary>
    /// Id
    /// </summary>
    [SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true, IsIdentity = true)]
    public virtual int Id { get; set; }
}

public abstract class BaseEntityCreate: BaseEntityId
{
    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnDescription = "创建时间", IsOnlyIgnoreUpdate = true, IsNullable = true)]
    public virtual DateTime? CreateTime { get; set; }
    /// <summary>
    /// 创建者Id
    /// </summary>
    [SugarColumn(ColumnDescription = "创建者Id", IsOnlyIgnoreUpdate = true, IsNullable = true)]
    public virtual long? CreateUserId { get; set; }
}

/// <summary>
/// 框架实体基类
/// </summary>
public abstract class BaseEntity : BaseEntityCreate
{    
    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true, IsNullable = true)]
    public virtual DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 修改者Id
    /// </summary>
    [SugarColumn(ColumnDescription = "修改者Id", IsOnlyIgnoreInsert = true, IsNullable = true)]
    public virtual long? UpdateUserId { get; set; }
}
public abstract class BaseDataEntity : BaseEntity
{
    /// <summary>
    /// 创建组织Id
    /// </summary>
    [SugarColumn(ColumnDescription = "创建组织Id")]
    public virtual long? CreateOrgId { get; set; }
}


/// <summary>
/// 框架实体树形基类：包含parentId
/// </summary>
public abstract class BaseTreeEntityId<T> : BaseEntityId
{
    /// <summary>
    /// ParentId
    /// </summary>
    [SugarColumn(ColumnName = "ParentId", ColumnDescription = "父节点id", IsNullable = true)]
    public virtual long ParentId { get; set; }
    /// <summary>
    /// 子节点
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public virtual List<T> Children { get; set; }
}

/// <summary>
/// 框架实体基类,包含子节点
/// </summary>
public abstract class BaseTreeEntity<T> : BaseTreeEntityId<T>
{
    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnDescription = "创建时间", IsOnlyIgnoreUpdate = true, IsNullable = true)]
    public virtual DateTime? CreateTime { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true, IsNullable = true)]
    public virtual DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 创建者Id
    /// </summary>
    [SugarColumn(ColumnDescription = "创建者Id", IsOnlyIgnoreUpdate = true, IsNullable = true)]
    public virtual long? CreateUserId { get; set; }

    /// <summary>
    /// 修改者Id
    /// </summary>
    [SugarColumn(ColumnDescription = "修改者Id", IsOnlyIgnoreInsert = true, IsNullable = true)]
    public virtual long? UpdateUserId { get; set; }
}

